package com.ruoyi.yzd.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yzd.domain.YzdAdministrator;
import com.ruoyi.yzd.service.IYzdAdministratorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 易制毒-管理员Controller
 * 
 * @author zyb
 * @date 2023-07-04
 */
@RestController
@RequestMapping("/access/administrator")
public class YzdAdministratorController extends BaseController
{
    @Autowired
    private IYzdAdministratorService yzdAdministratorService;

    /**
     * 查询易制毒-管理员列表
     */
    @PreAuthorize("@ss.hasPermi('access:administrator:list')")
    @GetMapping("/list")
    public TableDataInfo list(YzdAdministrator yzdAdministrator)
    {
        startPage();
        List<YzdAdministrator> list = yzdAdministratorService.selectYzdAdministratorList(yzdAdministrator);
        return getDataTable(list);
    }

    /**
     * 导出易制毒-管理员列表
     */
    @PreAuthorize("@ss.hasPermi('access:administrator:export')")
    @Log(title = "易制毒-管理员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YzdAdministrator yzdAdministrator)
    {
        List<YzdAdministrator> list = yzdAdministratorService.selectYzdAdministratorList(yzdAdministrator);
        ExcelUtil<YzdAdministrator> util = new ExcelUtil<YzdAdministrator>(YzdAdministrator.class);
        util.exportExcel(response, list, "易制毒-管理员数据");
    }

    /**
     * 获取易制毒-管理员详细信息
     */
    @PreAuthorize("@ss.hasPermi('access:administrator:query')")
    @GetMapping(value = "/{adminId}")
    public AjaxResult getInfo(@PathVariable("adminId") String adminId)
    {
        return success(yzdAdministratorService.selectYzdAdministratorByAdminId(adminId));
    }

    /**
     * 新增易制毒-管理员
     */
    @PreAuthorize("@ss.hasPermi('access:administrator:add')")
    @Log(title = "易制毒-管理员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YzdAdministrator yzdAdministrator)
    {
        return toAjax(yzdAdministratorService.insertYzdAdministrator(yzdAdministrator));
    }

    /**
     * 修改易制毒-管理员
     */
    @PreAuthorize("@ss.hasPermi('access:administrator:edit')")
    @Log(title = "易制毒-管理员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YzdAdministrator yzdAdministrator)
    {
        return toAjax(yzdAdministratorService.updateYzdAdministrator(yzdAdministrator));
    }

    /**
     * 删除易制毒-管理员
     */
    @PreAuthorize("@ss.hasPermi('access:administrator:remove')")
    @Log(title = "易制毒-管理员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{adminIds}")
    public AjaxResult remove(@PathVariable String[] adminIds)
    {
        return toAjax(yzdAdministratorService.deleteYzdAdministratorByAdminIds(adminIds));
    }
}
